package com.woniuxy02;

import java.util.Arrays;

/**
 * @author 作者
 * @create 2025-09-08 14:24
 */
public class Test02 {
    public static void main(String[] args) {
        Student[] students=new Student[3];
        students[0]=new Student(1,"zs",15);
        students[1]=new Student(2,"ls",17);
        students[2]=new Student(3,"ww",12);
        System.out.println("初始顺序");
        System.out.println(Arrays.toString(students));
        System.out.println("自然排序，年龄升序");
        //自然排序
        Arrays.sort(students);
        System.out.println(Arrays.toString(students));
        //自定义其他排序规则:年龄降序序
        System.out.println("自定义其他排序规则:年龄降序序");
        Arrays.sort(students,new StudentAgeDesc());
        System.out.println(Arrays.toString(students));
        System.out.println("自定义其他排序规则:姓名升序");
        Arrays.sort(students,new StudentNameAsc());
        System.out.println(Arrays.toString(students));

    }



}

